package com.jwdf.uda.ui.fragment.progress.manager;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.jwdf.uda.ui.fragment.progress.Constants;


public class PreferenceManager {
	private Context mContext;

	public PreferenceManager(Context context) {
		mContext = context;
	}

	private SharedPreferences getSharedPreferences() {
		return mContext.getSharedPreferences(Constants.PERFERENCE_NAME,
				Context.MODE_PRIVATE);
	}

	private Editor getEditer() {
		return getSharedPreferences().edit();
	}

	public float getFloatX() {
		SharedPreferences swg = getSharedPreferences();

		return swg.getFloat(Constants.PREF_KEY_FLOAT_X, 0f);
	}

	public void setFloatX(float x) {
		Editor editor = getEditer();
		editor.putFloat(Constants.PREF_KEY_FLOAT_X, x);
		editor.commit();
	}

	public float getFloatY() {
		SharedPreferences swg = getSharedPreferences();

		return swg.getFloat(Constants.PREF_KEY_FLOAT_Y, 0f);
	}

	public void setFloatY(float y) {
		Editor editor = getEditer();
		editor.putFloat(Constants.PREF_KEY_FLOAT_Y, y);
		editor.commit();
	}

	public boolean onlyDisplayOnHome() {
		SharedPreferences swg = getSharedPreferences();

		return swg.getBoolean(Constants.PREF_KEY_DISPLAY_ON_HOME, true);
	}

	public void setDisplayOnHome(boolean onlyDisplayOnHome) {
		Editor editor = getEditer();
		editor.putBoolean(Constants.PREF_KEY_DISPLAY_ON_HOME, onlyDisplayOnHome);
		editor.commit();
	}

	public boolean isDisplayRight() {
		SharedPreferences swg = getSharedPreferences();

		return swg.getBoolean(Constants.PREF_KEY_IS_RIGHT, false);
	}

	public void setDisplayRight(boolean isRight) {
		Editor editor = getEditer();
		editor.putBoolean(Constants.PREF_KEY_IS_RIGHT, isRight);
		editor.commit();
	}
}
